var QueryReport = {
	createNew: function() {
		var queryreport = {};
		queryreport.queryinfo = {};
		queryreport.queryResult = {};
		queryreport.infotype = "";
		/*----------------------------初始化查询条件------------------------------*/
		queryreport.initQueryParameterInfor = function(queryType) {
			var requestUrl = ('merchant' == queryType) ? 'ajax_merchant_report_info' : 'ajax_person_report_info';
			queryreport.infotype = ('merchant' == queryType) ? '2' : '1';
			requestUrl += "?u_id=" + getLocalStorage(STORATE_MANAGER.user).u_id;
			$.ajax({
				type: "GET",
				url: CONFIGER_MANAGER.DOMAIN + requestUrl,
				async: true,
				dataType: 'json',
			}).done(function(data) {
				if (false == data.success) {
					$.toast(data.error_msg);
					return;
				}
				queryreport.queryinfo = data;
				queryreport.paintTerm(data);
			}).always(function() {});

		};
		/*----------------------------选中查询项，画查询框------------------------------*/
		queryreport.paintTerm = function(data) {
			var apiinfo = data.data.api_info;
			var i = 0;
			var html = [];
			while (apiinfo[i]) {
				html.push('<li>');
				html.push('<p class="blackcolor_3 checktitle">' + apiinfo[i].name + '：</p>');
				html.push('<input id="' + apiinfo[i].name + '" name="all_' + apiinfo[i].name + '" tip=' + JSON.stringify(apiinfo[i].api_list) + ' class="checkInput" type="checkbox">');
				html.push('<label for="' + apiinfo[i].name + '" class="selecall">全选</label>');
				html.push('</li>');
				var j = 0;
				var apilist = apiinfo[i].api_list;
				if (apilist.length > 0) {
					html.push('<li>');
					html.push('<ul>');
					while (apilist[j]) {
						html.push('<li style="width:33%">');
						html.push('<input name="single" id="' + apilist[j].api_type + '" tip=' + JSON.stringify(apilist[j].params) + '  type="checkbox">');
						html.push('<label for="' + apilist[j].api_type + '">' + apilist[j].api_name + '</label>');
						html.push('</li>');
						j++;
					}
					html.push('</ul>');
					html.push('</li>');
				}
				i++;
			}
			$("#apiurl").val(data.data.api_url.substr(1));
			$("#peronalcheckinfor").html(html.join(''));
		};
		/*------------------------------选择查询条件------------------------------*/
		queryreport.bindChooseEvent = function() {

			//全选
			$(".personal_check").on("click", "input[name^=all_]", function() {
				var tip = JSON.parse($(this).attr('tip'));
				var isCheck = $(this).is(":checked");
				var id = $(this).attr('id');
				$(this).parent().next().find("input[type=checkbox]").prop("checked", isCheck);
				//画文本框
				queryreport.initTermData(tip, 'all', isCheck, id);

			});

			//单选
			$(".personal_check").on("click", "input[name=single]", function() {
				var isCheck = $(this).is(":checked");
				var tip = JSON.parse($(this).attr('tip'));
				var checkedCount = $(this).parent().parent().find("input[type=checkbox]:checked").length;
				var totalCount = $(this).parent().parent().find("input[type=checkbox]").length;
				var id = $(this).attr('id');
				if (checkedCount == totalCount) {
					$(this).parent().parent().parent().prev().find("input[name^=all_]").prop("checked", true);
				} else {
					$(this).parent().parent().parent().prev().find("input[name^=all_]").prop("checked", false);
				}
				//画文本框
				queryreport.initTermData(tip, "single", isCheck, id);
			});
		};
		/*------------------------------填充查询条件------------------------------*/
		queryreport.initTermData = function(list, type, isCheck, id) {
			var checkbox = $("input[name=single]:checked");
			var c6checkbox = $("input[id=C6][name=single]:checked");
			var c6Select = $("select[id=auth_type]");
			var selectOption = null;
			if (c6Select.length > 0) {
				selectOption = $("select[id=auth_type]").find("option:selected");
			}
			var selectedItem = $("input[name=selected_item]");
			var i = 0;
			var j = 0;
			var tip = null;
			var param = null;
			var keyArray = [];
			var item = [];
			var key = null;
			var id = null;

			while (checkbox[i]) {
				id = $(checkbox[i]).attr("id");
				tip = JSON.parse($(checkbox[i]).attr("tip"));
				j = 0;
				while (tip[j]) {
					key = tip[j].key;
					if (item.indexOf(key) == -1) {
						item[key] = tip[j];
						keyArray.push(key);
					}
					j++;
				}

				if (id == "C6") {
					if (c6Select && c6Select.length > 0) {
						if (selectOption && selectOption.length > 0) {
							j = 0;
							while (selectOption[j]) {
								tip = JSON.parse($(selectOption[j]).attr("tip"));
								params = tip.params;
								k = 0;
								while (params[k]) {
									key = params[k].key;
									if (item.indexOf(key) == -1) {
										item[key] = params[k];
										keyArray.push(key);
									}
									k++;
								}
								j++;
							}
						}
					}
				}
				i++;
			}

			keyArray.sort();
			i = 0;
			$("p[id^=p_][id!=p_queryreport]").remove();
			while (keyArray[i]) {
				queryreport.paintTextbox(item[keyArray[i]], true);
				i++;
			}
			//如果checkbox选择的个数大于0，隐藏提示，否则显示提示
			if ($("input[type=checkbox]:checked").length > 0) {
				$("#select_message").hide();
				$("#input_message").show();
			} else {
				$("#select_message").show();
				$("#input_message").hide();
			}
		};
		/*------------------------------填充查询条件，画出文本框------------------------------*/
		queryreport.paintTextbox = function(item, isChange) {
			if ($("#divTextBox").find("*[id=" + item.key + "]").length == 0) {
				var html = [];
				html.push('<p id="p_' + item.key + '">');
				html.push('<span class="blackcolor_3 checktitle">' + item.name + '：</span>');
				if ('String' == item.type) {
					html.push('<input name="selected_item" type="text" tip="' + item.type + '" id="' + item.key + '" value="" placeholder="' + item.name + '">');
				} else if ('date' == item.type) {
					html.push('<input name="selected_item" type="text" tip="' + item.type + '" id="' + item.key + '" value="" placeholder="2014-02-12" readonly onfocus="displayCalendar(this, \'yyyy-mm-dd\', this, true)" />');
				} else if ('list' == item.type) {
					var i = 0;
					html.push('<select name="selected_item" tip="' + item.type + '" id="' + item.key + '">');
					var valueLength = item.value_list.length;
					while (item.value_list[i]) {
						if (i == (valueLength - 1)) {
							html.push('<option selected="selected" tip=' + JSON.stringify(item.value_list[i]) + ' value="' + item.value_list[i].key + '">' + item.value_list[i].value + '</option>')
						} else {
							html.push('<option tip=' + JSON.stringify(item.value_list[i]) + ' value="' + item.value_list[i].key + '">' + item.value_list[i].value + '</option>')
						}
						i++;
					}
					html.push('</select>');
					queryreport.authtypeChange(item.value_list);
				}
				if (item.is_required == "1") {
					html.push('<span name="' + item.key + '" class="select_icon_blank"></span>');
					html.push('<span tip="' + item.name + '" name="' + item.key + '_title" class="graycolor_9 px13">请填写' + item.name + '</span>');
				}
				html.push('</p>');
				if (isChange) {
					$("#p_queryreport").before(html.join(''));
				} else {
					$(html.join('')).prependTo($("#divTextBox"));
				}
			}
		};
		/*------------------------------根据下拉框选择查询项------------------------------*/
		queryreport.authtypeChange = function(list) {
			$(".content").on("change", "#auth_type", function() {
				var checkbox = $("input[id!=C6][name=single]:checked");
				var isAlsoexit = false;
				var tips = JSON.parse($(this).find("option:selected").attr("tip"));
				var sParams = tips.params;
				var sItem = $("*[name=selected_item][id!=auth_type]");
				var needItems = [];
				var currentItems = [];
				var key = '';
				var i = 0;
				var j = 0;
				var html = [];

				$("p[id^=p_][id!=p_auth_type][id!=p_queryreport]").remove();

				//遍历当前选中的option里面要画的
				i = 0;
				while (sParams[i]) {
					key = sParams[i].key;
					if (needItems.indexOf(key) == -1) {
						needItems.push(key);
						queryreport.paintTextbox(sParams[i], true);
					}
					i++;
				}

				//checkbox中要画的
				i = 0;
				while (checkbox[i]) {
					tip = JSON.parse($(checkbox[i]).attr("tip"));
					j = 0;
					while (tip[j]) {
						key = tip[j].key;
						if (needItems.indexOf(key) == -1) {
							needItems.push(key);
							queryreport.paintTextbox(tip[j], true);
						}
						j++;
					}
					i++;
				}

			});

		};
		/*------------------------------点击查询------------------------------*/
		queryreport.bindCheckReport = function() {

			$("#queryreport").on("click", function() {

				var input = $("input[type=text]");
				var select = $("select");
				var checkbox = $("input:checkbox[name=single]:checked");
				var typesArray = [];
				var requestUrl = $("#apiurl").val();
				var requestData = {};
				var i = 0;

				//查询条件个数
				if (input.length == 0) {
					$.toast('请选择查询条件');
				}

				//文本框内容非空验证
				i = 0;
				while (input[i]) {
					var type = $(input[i]).attr('tip');

					//必填项
					if ($("span[name=" + $(input[i]).prop('id') + "]").length > 0) {
						var title = $(input[i]).prop('placeholder');
						//需要验证非空
						if ($(input[i]).val() == '') {
							$("span[name=" + $(input[i]).prop('id') + "]").removeClass('select_icon_blank').addClass('select_icon_red').html("×");
							$(input[i]).addClass("unvalidate");
							return;
						}
						//时间格式验证
						if ('date' == type && !DateFormatter.DateISO($(input[i]).val(), 'yyyy-MM-dd')) {
							$("span[name=" + $(input[i]).prop('id') + "]").removeClass('select_icon_blank').addClass('select_icon_red').html("×");
							$("span[name=" + $(input[i]).prop('id') + "_title]").html('时间格式不正确');
							$(input[i]).addClass("unvalidate");
							return;
						} else {
							$(input[i]).nextAll(":first").removeClass('select_icon_red').addClass('select_icon_green').html("✓");
							$("span[name=" + $(input[i]).prop('id') + "_title]").html('请填写' + title);
						}
						//手机号验证
						if ("mobile" == $(input[i]).prop('id') && !isTelephone($(input[i]).val())) {
							$("span[name=" + $(input[i]).prop('id') + "]").removeClass('select_icon_blank').addClass('select_icon_red').html("×");
							$("span[name=" + $(input[i]).prop('id') + "_title]").html(title + '格式不正确');
							$(input[i]).addClass("unvalidate");
							return;
						} else {
							$(input[i]).nextAll(":first").removeClass('select_icon_red').addClass('select_icon_green').html("✓");;
							$("span[name=" + $(input[i]).prop('id') + "_title]").html('请填写' + title);
						}
						//身份证号
						if ("cid" == $(input[i]).prop('id') && !isIDno($(input[i]).val())) {
							$("span[name=" + $(input[i]).prop('id') + "]").removeClass('select_icon_blank').addClass('select_icon_red').html("×");
							$("span[name=" + $(input[i]).prop('id') + "_title]").html(title + '格式不正确');
							$(input[i]).addClass("unvalidate");
							return;
						} else {
							$(input[i]).nextAll(":first").removeClass('select_icon_red').addClass('select_icon_green').html("✓");;
							$("span[name=" + $(input[i]).prop('id') + "_title]").html('请填写' + title);
						}
						//姓名
						if ("name" == $(input[i]).prop('id')) {
							if (title.indexOf("企业") == -1) {
								if (!isChineseName($(input[i]).val())) {
									$("span[name=" + $(input[i]).prop('id') + "]").removeClass('select_icon_blank').addClass('select_icon_red').html("×");
									$("span[name=" + $(input[i]).prop('id') + "_title]").html(title + '为2至5个汉字');
									$(input[i]).addClass("unvalidate");
									return;
								}
							} else {
								if ($(input[i]).val().length < 5) {
									$("span[name=" + $(input[i]).prop('id') + "]").removeClass('select_icon_blank').addClass('select_icon_red').html("×");
									$("span[name=" + $(input[i]).prop('id') + "_title]").html(title + '至少5个字');
									$(input[i]).addClass("unvalidate");
									return;
								}
							}
						} else {
							$(input[i]).nextAll(":first").removeClass('select_icon_red').addClass('select_icon_green').html("✓");;
							$("span[name=" + $(input[i]).prop('id') + "_title]").html('请填写' + title);
						}
						//银行卡号
						if ("card" == $(input[i]).prop('id') && !cardCheck($(input[i]).val())) {
							$("span[name=" + $(input[i]).prop('id') + "]").removeClass('select_icon_blank').addClass('select_icon_red').html("×");
							$("span[name=" + $(input[i]).prop('id') + "_title]").html(title + '格式不正确');
							$(input[i]).addClass("unvalidate");
							return;
						} else {
							$(input[i]).nextAll(":first").removeClass('select_icon_red').addClass('select_icon_green').html("✓");;
							$("span[name=" + $(input[i]).prop('id') + "_title]").html('请填写' + title);
						}

						requestData[$(input[i]).prop('id')] = $(input[i]).val();
					} else {
						requestData[$(input[i]).prop('id')] = $(input[i]).val();
					}
					i++;
				}

				//时间比较
				var bedinDate = Date.parse(requestData.begin_date);
				var endDate = Date.parse(requestData.end_date);
				if (bedinDate > endDate) {
					$.toast("开始时间大于结束时间");
					return;
				}

				i = 0;
				while (select[i]) {
					requestData[$(select[i]).prop('id')] = $(select[i]).val();
					i++;
				}

				i = 0
				while (checkbox[i]) {
					typesArray.push($(checkbox[i]).attr('id'));
					i++;
				}
				requestData.types = typesArray.join(",");

				//账户检查
				$.ajax({
					type: "GET",
					url: CONFIGER_MANAGER.DOMAIN + "ajax_check_amount?types=" + requestData.types + "?u_id=" + getLocalStorage(STORATE_MANAGER.user).u_id,
					async: true
				}).done(function(data) {
					if (data.succes) {
						$(".amountcheck").show();
						return;
					} else {
						$(".amountcheck").hide();
					}
					//查询
					$.ajax({
						type: "GET",
						url: CONFIGER_MANAGER.DOMAIN + requestUrl + "?u_id=" + getLocalStorage(STORATE_MANAGER.user).u_id,
						//					url : "http://121.41.6.183:9999/ajax_query_personal_report?types=C1&card=6225057447475033020",
						async: true,
						data: requestData,
						dataType: "JSON",
						//beforeSend: function() {							$.showWaiting();						}
					}).done(function(data) {
						if (data.success) {
							//queryreport.paintQueryResult(data);
							//queryreport.queryResult = data;
							var info_type = ("ajax_query_personal_report" == requestUrl) ? "1" : "2";
							redirect("result.html?trans_log_no=" + data.data.trans_log_no + "&info_type=" + info_type);
						} else {
							$.toast(data.error_code);
						}
					}).fail(function(data) {

					}).always(function() {
						$.closeWaiting();
					});

				});
			});

		};
		/*------------------------------画查询结果------------------------------*/
		//个人查询，企业查询
		queryreport.paintQueryResult = function(data) {
			var i = 0;
			var html = [];
			html.push(queryreport.paintQueryItem(data, null));
			html.push(queryreport.paintQueryItemResult(data));
			$(".rightcontent").html(html.join(''));
		};
		//历史查询
		queryreport.paintHisQueryResult = function(data, apiinfo) {
			var i = 0;
			var html = [];
			html.push(queryreport.paintQueryItem(data, apiinfo));
			html.push(queryreport.paintQueryItemResult(data));
			html.push(queryreport.paintDisclaimer());
			queryreport.queryinfo = apiinfo;
			queryreport.queryResult = data;
			$(".rightcontent").html(html.join(''));
		};
		/*------------------------------查询类目------------------------------*/
		queryreport.paintQueryItem = function(data, queryApiinfor) {
			var html = [];
			var addedParam = [];
			var apinos = data.data.api_nos;
			var params = data.data.params_json;
			var apiinfor = (queryApiinfor == null) ? queryreport.queryinfo.data.api_info : queryApiinfor.data.api_info;
			var i = 0;
			var j = 0;
			var k = 0;
			var m = 0;
			html.push('<div>');
			var title = "个人用户报告页";
			if (data.data.api_nos[0].indexOf('B') > -1) {
				title = "企业用户报告页";
			}
			html.push('<h2>' + title + '<input type="submit" value="打印报告" id="printreport" class="print"></h2>');
			html.push('<div class="rightcontent_innerdiv">');
			html.push('<h3 class="h1_personal">用户基本信息</h3>');
			html.push('<ul id="personalinfo" class="lin50">');
			for (var checkParam in params) {
				j = 0;
				while (apiinfor[j]) {
					var apilist = apiinfor[j].api_list;
					k = 0;
					while (apilist[k]) {
						var param = apilist[k].params;
						m = 0;
						while (param[m]) {
							if (param[m].key == checkParam && (addedParam.indexOf(checkParam) == -1)) {
								addedParam.push(checkParam);
								html.push('<li style="width:32%;">');
								html.push('<p id="p_checkparam_' + checkParam + '" class="blackcolor_3 resulttitle"><label class="titlefont titlelabel">' + param[m].name + '：</label><span>' + params[checkParam] + '</span></p>');
								html.push('</li>');
							}
							m++;
						}
						k++;
					}
					j++;
				}
			}
			html.push('</ul>');

			//画查询类目 不要了
			//			html.push('<h3 class="h1_checkitem">查询类目');
			//			html.push('<span style="margin-left: 16px;"><input id="showAll" type="checkbox" checked >');
			//			html.push('<label for="showAll" style="font-weight: 400; color: #666666;font-size:13px;">全选(点击可隐藏类目)</label></span>');
			//			html.push('</h3>');
			//			html.push('<ul id="personalinfo">');
			//			i = 0;			
			//			var queryArray = getLocalStorage(STORATE_MANAGER.queryParamArray);
			//			while (apinos[i]) {
			//				html.push('<li style="width: 32%;">');
			//				html.push('<input id="' + apinos[i] + '" type="checkbox" checked>');
			//				html.push('<label for=' + apinos[i] + '>' + queryArray[apinos[i]] + '</label>');
			//				html.push('</li>');
			//				i++;
			//			}
			//			html.push('</ul>');

			html.push('</div>');
			html.push('</div>');
			return html.join('');
		};

		/*------------------------------查询接口项------------------------------*/
		queryreport.paintQueryItemResult = function(data) {
			var html = [];
			var ddata = data.data.data;
			var getType = Object.prototype.toString;
			var queryParamArray = getLocalStorage(STORATE_MANAGER.queryParamArray);
			for (var dkey in ddata) {

				var result = ddata[dkey].result;
				var type = getType.call(result);
				switch (type) {
					case '[object String]':
						{
							html.push('<div name="divcheckitem" id="' + ddata[dkey].key + '">');
							html.push('<h1 class="title_1_h2">' + ddata[dkey].name + '</h1>');
							html.push('<h2>' + ddata[dkey].name + '</h2>');
							html.push('<div class="rightcontent_innerdiv">');
							html.push('<ul class="personal_check">');

							type = getType.call(result);
							//							html.push('<li class="li_h1">');
							//							html.push('<img src="images/result/u157.png">');
							//							html.push('<h3 class="redborder blackcolor_3">' + ddata[dkey].name + '</h3>');
							//							html.push('</li>');
							html.push('<li class="li_tab">');
							html.push('<table border="1" cellspacing="0px" class="table-box">');
							html.push('<tbody>');
							html.push('<tr>');
							if (isNaN(result)) {
								html.push(result);
							} else {
								html.push('<td>');
								html.push(((result == '1') ? "认证成功" : "认证失败"));
								html.push('</td>');
							}
							html.push('</tr>')
							html.push('</tbody>');
							html.push('</table>');
							html.push('</li>');

							html.push('</ul>');
							html.push('</div>');
							html.push('</div>');
						}
						break;

					case "[object Array]":
						{
							var i = 0;
							//							html.push('<li class="li_h1">');
							//							html.push('<img src="images/result/u157.png">');
							//							html.push('<h3 class="redborder blackcolor_3">' + thisUtilities.ResultItem[dkey].name + '</h3>');
							//							html.push('</li>');
							if (["judgement"].indexOf(dkey) > -1) {
								html.push('<div name="divcheckitem" id="' + ddata[dkey].key + '">');
								html.push('<h1 class="title_1_h2">' + ddata[dkey].name + '</h1>');
								html.push('<h2>' + ddata[dkey].name + '</h2>');
								html.push('<div class="rightcontent_innerdiv">');
								html.push('<ul class="personal_check">');

								var judegCount = result.length;

								html.push('<li class="li_tab">');
								html.push('<table border="1" cellspacing="0px" class="table-box">');
								html.push('<tbody>');
								html.push('<tr>');
								html.push('<td style="width:50%;"><label class="titlefont">判决信息：</label><label class="redcolorB10319blod">' + (judegCount > 0 ? '有' : '无') + '</label></td>');
								html.push('<td><label class="titlefont">法院判决次数：</label><label class="redcolorB10319blod">' + judegCount + '次</label></td>');
								html.push('</tr>');
								html.push('</tbody>');
								html.push('</table>');
								html.push('</li>');

								if (judegCount > 0) {
									html.push('<li class="li_tab">');
									html.push('<table border="1" cellspacing="0px" class="table-box">');
									html.push('<tbody>');
									var columnCount = 2;
									var count = result.length;
									while (result[i]) {
										if ((i % columnCount) == 0) {
											html.push('<tr><td style="width:50%;">' + result[i] + '</td>');
										} else {
											html.push('<td>' + result[i] + '</td></tr>');
										}
										if (((i + 1) == count) && (i % columnCount) == 0) {
											html.push('<td>' + '' + '</td></tr>');
										}
										i++;
									}
									html.push('</tbody>');
									html.push('</table>');
									html.push('</li>');
								}

								html.push('</ul>');
								html.push('</div>');
								html.push('</div>');
							} else if (["merchant_verify"].indexOf(dkey) > -1) {
								html.push('<div name="divcheckitem" id="' + ddata[dkey].key + '">');
								html.push('<h1 class="title_1_h2">' + ddata[dkey].name + '</h1>');
								html.push('<h2>' + ddata[dkey].name + '</h2>');
								html.push('<div class="rightcontent_innerdiv">');
								html.push('<ul class="personal_check">');

								html.push('<li class="li_tab">');
								html.push('<table border="1" cellspacing="0px" class="table-box">');
								html.push('<tbody>');
								html.push('<tr>');								
								html.push('<th>' + thisUtilities.ResultItem[dkey].pName.transTime + '</th>');
								html.push('<th>' + thisUtilities.ResultItem[dkey].pName.transAmount + '</th>');
								html.push('</tr>');
								while (result[i]) {
									html.push('<tr>');
									html.push('<td>' + result[i].transTime + '</td>');
									html.push('<td style="width:50%;">' + result[i].transAmount + '</td>');
									html.push('</tr>');
									i++;
								}
								html.push('</tbody>');
								html.push('</table>');
								html.push('</li>');

								html.push('</ul>');
								html.push('</div>');
								html.push('</div>');
							} else {
								html.push('<div name="divcheckitem" id="' + ddata[dkey].key + '">');
								html.push('<h1 class="title_1_h2">' + ddata[dkey].name + '</h1>');
								html.push('<h2>' + ddata[dkey].name + '</h2>');
								html.push('<div class="rightcontent_innerdiv">');
								html.push('<ul class="personal_check">');
								while (result[i]) {
									html.push('<li class="li_tab">');
									html.push('<table border="1" cellspacing="0px" class="table-box">');
									html.push('<tbody>');
									type = getType.call(result[i]);
									html.push(queryreport.paintObject(result[i], dkey));
									html.push('</tbody>');
									html.push('</table>');
									html.push('</li>');
									i++;
								}

								html.push('</ul>');
								html.push('</div>');
								html.push('</div>');
							}
						}
						break;
					case "[object Object]":
						{
							//对象包含对象
							if (['bank_card_report', 'trans_location_stat', 'merchant_report', 'enterprise_info'].indexOf(dkey) > -1) {
								html.push('<div name="divcheckitem" id="' + ddata[dkey].key + '">');
								html.push('<h1 class="title_1_h2">' + ddata[dkey].name + '</h1>');
								for (var key in result) {
									html.push('<h2 class="inner_h2">' + thisUtilities.ResultItem[key].name + '</h2>');
									html.push('<div class="rightcontent_innerdiv">');
									html.push('<ul class="personal_check">');

									type = getType.call(result[key]);
									//									html.push('<li class="li_h1">');
									//									html.push('<img src="images/result/u157.png">');
									//									html.push('<h3 class="redborder blackcolor_3">' + thisUtilities.ResultItem[key].name + '</h3>');
									//									html.push('</li>');
									html.push('<li class="li_tab">');
									html.push('<table border="1" cellspacing="0px" class="table-box">');
									html.push('<tbody>');
									if (type == "[object String]") {
										html.push(queryreport.paintString(result[key], key));
									} else if (type == "[object Array]") {
										html.push(queryreport.paintArray(result[key], key));
									} else if (type == "[object Object]") {
										html.push(queryreport.paintObject(result[key], key));
									}
									html.push('</tbody>');
									html.push('</table>');
									html.push('</li>');

									html.push('</ul>');
									html.push('</div>');
								}
								html.push('</div>');
							} //对象包含数组，个人职业资格证书
							else if (['professional_certs'].indexOf(dkey) > -1) {
								html.push('<div name="divcheckitem" id="' + ddata[dkey].key + '">');
								html.push('<h1 class="title_1_h2">' + ddata[dkey].name + '</h1>');
								html.push('<h2>' + thisUtilities.ResultItem[dkey].name + '</h2>');
								html.push('<div class="rightcontent_innerdiv">');
								html.push('<ul class="personal_check">');

								html.push('<li class="li_tab">');
								html.push('<table border="1" cellspacing="0px" class="table-box">');
								html.push('<tbody>');
								html.push('<tr>');
								html.push('<td style="width:33.3%"><label class="titlefont">' + thisUtilities.ResultItem[dkey].pName.name + '：</label>'+ result.name +'</td>');
								html.push('<td style="width:33.3%"><label class="titlefont">' + thisUtilities.ResultItem[dkey].pName.certificateID + '：</label>'+ result.certificateID +'</td>');
								html.push('<td></td>');
								html.push('</tr>');
								html.push('</tbody>');
								html.push('</table>');
								html.push('</li>');
								
								var list = result.list;
								$.each(list, function(key, item) {
									html.push('<li class="li_tab">');
									html.push('<table border="1" cellspacing="0px" class="table-box">');
									html.push('<tbody>');
									html.push(queryreport.paintObject(item, dkey));
									html.push('</tbody>');
									html.push('</table>');
									html.push('</li>');									
								});
								


								html.push('</ul>');
								html.push('</div>');
								html.push('</div>');

							}
							//对象包含图片
							else if (['id_photo', 'education'].indexOf(dkey) > -1) {
								//								html.push('<li class="li_h1">');
								//								html.push('<img src="images/result/u157.png">');
								//								html.push('<h3 class="redborder blackcolor_3">' + thisUtilities.ResultItem[dkey].name + '</h3>');
								//								html.push('</li>');
								html.push('<div name="divcheckitem" id="' + ddata[dkey].key + '">');
								html.push('<h1 class="title_1_h2">' + ddata[dkey].name + '</h1>');
								html.push('<h2>' + thisUtilities.ResultItem[dkey].name + '</h2>');
								html.push('<div class="rightcontent_innerdiv">');
								html.push('<ul class="personal_check">');

								html.push('<li class="li_tab">');
								html.push('<table>');
								html.push('<tbody>');
								html.push(queryreport.piantPhotoObject(result, dkey));
								html.push('</tbody>');
								html.push('</table>');
								html.push('</li>');

								html.push('</ul>');
								html.push('</div>');
								html.push('</div>');
							}
							//对象中有布尔类型，如果是否不用画其他的，是就画
							else if (['dishonesty', 'p2p_black'].indexOf(dkey) > -1) {
								html.push('<div name="divcheckitem" id="' + ddata[dkey].key + '">');
								html.push('<h1 class="title_1_h2">' + ddata[dkey].name + '</h1>');
								html.push('<h2>' + ddata[dkey].name + '</h2>');
								html.push('<div class="rightcontent_innerdiv">');
								html.push('<ul class="personal_check">');
								html.push('<li class="li_tab">');

								if (result.hasOwnProperty('is_have')) {
									//result.is_have = true;
									if (result.is_have) {
										html.push('<table border="1" cellspacing="0px" class="table-box">');
										html.push('<tbody>');
										html.push('<td style="border-bottom: 0;">');
										html.push('<label class="titlefont">');
										html.push(thisUtilities.ResultItem[dkey].pName.is_have);
										html.push('： </label>');
										html.push('<label class="redcolorB10319blod">是</label>');
										html.push('</td>');
										html.push('</tbody>');
										html.push('</table>');
										delete result['is_have'];
										html.push('<table border="1" cellspacing="0px" class="table-box">');
										html.push('<tbody>');
										html.push(queryreport.paintObject(result, dkey, 2));
										html.push('</tbody>');
										html.push('</table>');
									} else {
										html.push('<table border="1" cellspacing="0px" class="table-box">');
										html.push('<tbody>');
										html.push('<td>');
										html.push('<label class="titlefont">');
										html.push(thisUtilities.ResultItem[dkey].pName.is_have);
										html.push('： </label>');
										html.push('<label class="redcolorB10319blod">否</label>');
										html.push('</td>');
										html.push('</tbody>');
										html.push('</table>');
									}
								} else {
									html.push('<table border="1" cellspacing="0px" class="table-box">');
									html.push('<tbody>');
									html.push(queryreport.paintObject(result, dkey));
									html.push('</tbody>');
									html.push('</table>');
								}

								html.push('</li>');
								html.push('</ul>');
								html.push('</div>');
								html.push('</div>');
							}
							//对象包含元素
							else {
								//								html.push('<li class="li_h1">');
								//								html.push('<img src="images/result/u157.png">');
								//								html.push('<h3 class="redborder blackcolor_3">' + thisUtilities.ResultItem[dkey].name + '</h3>');
								//								html.push('</li>');
								html.push('<div name="divcheckitem" id="' + ddata[dkey].key + '">');
								html.push('<h1 class="title_1_h2">' + ddata[dkey].name + '</h1>');
								html.push('<h2>' + ddata[dkey].name + '</h2>');
								html.push('<div class="rightcontent_innerdiv">');
								html.push('<ul class="personal_check">');

								html.push('<li class="li_tab">');
								html.push('<table border="1" cellspacing="0px" class="table-box">');
								html.push('<tbody>');
								html.push(queryreport.paintObject(result, dkey));
								html.push('</tbody>');
								html.push('</table>');
								html.push('</li>');

								html.push('</ul>');
								html.push('</div>');
								html.push('</div>');
							}
						}
						break;
				}
			}
			return html.join('');
		};

		/*------------------------------字符串类型------------------------------*/
		queryreport.paintString = function(data, key) {
			var html = [];
			html.push('<tr>');
			html.push('<td class="titlefont" style="color:#000000;width:50%;text-align:center;">区间值（元）</td>');
			html.push('<td style="text-align:center;">' + data + '</td>');
			html.push('</tr>');
			return html.join('');
		};
		/*------------------------------对象类型------------------------------*/
		queryreport.paintObject = function(data, propertyKey, column) {
			var html = [];
			var count = 0;
			var multiplueColumn = false;
			if (['indexContrast'].indexOf(propertyKey) > -1) {
				for (var key in data) {
					html.push('<tr>');
					html.push('<td>' + key + '</td>');
					for (var innerkey in data[key]) {
						html.push('<td>' + data[key][innerkey] + '</td>');
					}
					html.push('</tr>');
				}
			} else {
				if (!column) {
					column = 3;
				}
				var size = 0;
				var pName = thisUtilities.ResultItem[propertyKey].pName;
				for (var key in pName) {
					size++;
				}
				size = size - 1;
				for (var key in pName) {
					if ((count % column) == 0) {
						html.push('<tr>');
					}
					var getType = Object.prototype.toString;
					var type = getType.call(data[key]);
					if (["idCardPhoto", "photo"].indexOf(key) > -1) {
						html.push('<td class="titlefont" style="width:33.3%;">');
						html.push(thisUtilities.ResultItem[propertyKey].pName[key] + ":");
						html.push('<img id="idCardPhoto" width="20px" height="16px" src="data:image/png;base64,' + data[key] + '">')
						html.push('</td>');
					} else {
						html.push('<td style="width:33.3%;">');
						html.push('<label class="titlefont">' + thisUtilities.ResultItem[propertyKey].pName[key] + "： </label>");
						html.push(((type == "[object Boolean]") ? ((data[key] == true) ? "<label class='redcolorB10319blod'>是<label/>" : "<label class='redcolorB10319blod'>否</label>") : (['entStatus'].indexOf(key) > -1) ? ('<label class="redcolorB10319blod">' + data[key] + '</label>') : data[key]));
						html.push('</label>');
						html.push('</td>');
					}
					//最后补充空白td
					if ((size == count) && [0, 1].indexOf(count % column) > -1) {
						var leftCount = column - (size % column) - 1;
						for (var i = 0; i < leftCount; i++) {
							html.push('<td style="width:33.3%;"></td>');
						}
					}
					if ((count % column) == (column - 1)) {
						html.push('</tr>');
					}
					count++;
				}

			}
			return html.join('');
		};
		/*------------------------------画带有图片的对象------------------------------*/
		queryreport.piantPhotoObject = function(data, propertyKey) {
			var html = [];
			var pName = thisUtilities.ResultItem[propertyKey].pName;
			var photo = "";
			if ("id_photo" == propertyKey) {
				photo = pName.idCardPhoto;
				html.push('<tr>');
				if (data.idCardPhoto) {
					html.push('<td style="width:200px;">');
					html.push('<img id="idCardPhoto"  src="data:image/png;base64,' + data.idCardPhoto + '"/>');
					html.push('</td>');
				}
				html.push('<td style="vertical-align:middle;padding-left:1%;">');
				html.push('<table border="1" cellspacing="0px" class="table-box">');
				html.push('<tr>');
				html.push('<td class="imgtd"><label>' + pName.cid + "：</label>" + data.cid + '</td>');
				html.push('<td class="imgtd"><label>' + pName.name + "：</label>" + data.name + '</td>');
				html.push('</tr>');
				html.push('<tr>');
				html.push('<td class="imgtd"><label>' + pName.message + "：</label>" + data.message + '</td>');
				html.push('<td class="imgtd">附：个人身份证照片</td>');
				html.push('</tr>');
				html.push('</table>');
				html.push('</td>');

				html.push("</tr>");
			} else if ("education" == propertyKey) {
				html.push('<tr>');
				if (data.photo) {
					html.push('<td style="width:200px;">');
					html.push('<img id="photo"  src="data:image/png;base64,' + data.photo + '">');
					html.push('</td>');
				}
				html.push('<td style="vertical-align:middle;padding-left:1%;">');
				html.push('<table border="1" cellspacing="0px" class="table-box">');

				html.push('<tr>');
				html.push('<td class="imgtd"><label>' + pName.name + "：</label>" + data.name + '</td>');
				html.push('<td class="imgtd"><label>' + pName.cid + "：</label>" + data.cid + '</td>');				
				html.push("</tr>");
				html.push('<tr>');
				html.push('<td class="imgtd"><label>' + pName.graduate + "：</label>" + data.graduate + '</td>');
				html.push('<td class="imgtd"><label>' + pName.studyResult + "：</label>" + data.studyResult + '</td>');				
				html.push("</tr>");
				html.push('<tr>');
				html.push('<td class="imgtd"><label>' + pName.educationDegree + "：</label>" + data.educationDegree + '</td>');
				html.push('<td class="imgtd"><label>' + pName.specialityName + "：</label>" + data.specialityName + '</td>');				
				html.push("</tr>");
				html.push('<tr>');
				html.push('<td class="imgtd"><label>' + pName.enrolDate + "：</label>" + data.enrolDate + '</td>');
				html.push('<td class="imgtd"><label>' + pName.graduateTime + "：</label>" + data.graduateTime + '</td>');				
				html.push("</tr>");
				html.push('<tr>');				

				html.push('</table>');
				html.push('</td>');

				html.push("</tr>");
			}
			return html.join('');
		};
		/*------------------------------数组类型------------------------------*/
		queryreport.paintArray = function(data, propertyKey) {
			var html = [];
			var pName = thisUtilities.ResultItem[propertyKey].pName;
			var cCount = thisUtilities.ResultItem[propertyKey].cCount;
			var count = 0;
			var j = 0;
			var subNames = [];
			if (cCount > 5) {
				while (data[j]) {
					if (j > 0) {
						html.push('<tr><td style="width:100%;" colspan="3"></td></tr>');
					}
					html.push(queryreport.paintObject(data[j], propertyKey, 3));
					j++;
				}
			} else {
				html.push('<tr>');
				for (var key in pName) {
					html.push('<th>' + pName[key] + '</th>');
					count++;
				}
				html.push('</tr>');
				var styleString = "width:" + (100 / count).toFixed(2) + "%;";
				for (var i = 0; i < data.length; i++) {
					html.push('<tr>');
					var k = 0;
					for (var key in pName) {
						subNames = key.split("_");
						if (subNames.length > 2) {
							var j = 0;
							var combinStr = "";
							while (subNames[j]) {
								combinStr += ((j == 0) ? "" : ",") + data[i][subNames[j]];
								j++;
							}
							html.push('<td ' + (0 == k ? 'class="titlefont boldfont"' : '') + ' style=' + styleString + '>' + combinStr + '</td>');
						} else {
							html.push('<td ' + (0 == k ? 'class="titlefont boldfont"' : '') + ' style=' + styleString + '>' + data[i][key] + '</td>');
						}
						k++;
					}
					html.push('</tr>');
				}
			}
			return html.join('');
		};
		/*------------------------------画免责申明------------------------------*/
		queryreport.paintDisclaimer = function() {
			var html = [];
			html.push("<div class='disclaimer'>");
			html.push('<div class="rightcontent_innerdiv" style="border-top:1px solid #E0E0E0;">');
			html.push('<div>');
			//html.push('<p>免责说明：</p>');
			html.push('<p>报告阅读须知</p>');
			html.push('<p>1.本报告的著作权属于杭州我要借企业征信有限公司，未经书面许可，不得擅自复制、摘录、编辑、转载、披露和发表。</p>');
			html.push('<p>2.本报告仅供查询机构参考，不起任何证明作用。且本报告仅限查询依照法律法规规章所规定的查询用途使用，不得擅自向任何非查询人或机构泄露和发布本报告的所涉及的任何信息。</p>');
			html.push('<p>3.本报告的生成依据是截至报告时间为止的企业征信数据库中的相关信息。</p>');
			html.push('<p>4.征信机构承诺保持其客观、中立的地位，并保证将这一原则贯穿于信息汇总、加工、整合的全过程中。</p>');
			html.push('<p>5.请妥善保管本报告，并注意保密。</p>');
			html.push('</div>');
			html.push('</div>');
			html.push('</div>');
			return html.join('');
		};
		/*------------------------------输入状态------------------------------*/
		queryreport.inputOnInput = function() {
			$(".rightcontent").on("click", "input.unvalidate", function() {
				$(this).nextAll(":first").removeClass('select_icon_red').addClass('select_icon_green').html("✓");;
			});
		};
		/*------------------------------打印报告------------------------------*/
		queryreport.printReport = function() {
			$(".rightcontent").on("click", "#printreport", function() {
				setLocalStorage(STORATE_MANAGER.queryinfo, queryreport.queryinfo);
				setLocalStorage(STORATE_MANAGER.queryresult, queryreport.queryResult);
				redirect("print.html?info_type=" + queryreport.infotype);
			});
		};
		/*------------------------------显示隐藏查询结果------------------------------*/
		queryreport.selectResultItem = function() {
			var isCheck = false;
			//显示所有
			$(".rightcontent,.date-box").on("click", "#showAll", function() {
				isCheck = $(this).is(":checked");
				$("input[type=checkbox]").prop("checked", isCheck);
				if (isCheck) {
					$("div[name=divcheckitem]").show();
				} else {
					$("div[name=divcheckitem]").hide();
				}
			});
			//显示单个
			$(".rightcontent,.date-box").on("click", "ul#personalinfo li input[type=checkbox]", function() {
				var length = $("#personalinfo input[type=checkbox]").length;
				var count = $("#personalinfo input[type=checkbox]:checked").length;
				if (length == count) {
					$("#showAll").prop("checked", true);
				} else {
					$("#showAll").prop("checked", false);
				}
				var id = $(this).attr("id");
				isCheck = $(this).is(":checked");
				if (id == "B4") {
					id = "C8";
				}
				if (isCheck) {
					$("div[id=" + id + "]").show();
				} else {
					$("div[id=" + id + "]").hide();
				}
			});

		};
		/*------------------------------------------------------------*/
		return queryreport;
	}
};;